package com.gears_software.sxdc.dccx.data.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.gears_software.sxdc.dccx.data.model.VehicleModel;
import com.gears_software.sxdc.dccx.ui.view.MyCarListItemView;
import com.gears_software.sxdc.dccx.ui.view.MyCarListItemView_;
import com.gears_software.sxdc.dccx.ui.view.MyTripListItemView;
import com.gears_software.sxdc.dccx.ui.view.MyTripListItemView_;

import java.util.List;


/**
 * Created by chezhenzhen on 2017/6/27.
 * 我的车辆adapter
 */

public class MyCarListAdapter extends BaseAdapter {
    Context context;
    List<VehicleModel> list;

    public MyCarListAdapter(Context context, List<VehicleModel> list) {
        super();
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }
    @Override
    public VehicleModel getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        MyCarListItemView itemView;
        if (convertView == null) {
            itemView = MyCarListItemView_.build(context);
        } else {
            itemView = (MyCarListItemView) convertView;
        }
        itemView.bind(list.get(position),position);
        return itemView;
    }
}
